﻿dateFormat = "yy-m-d";
dateTimeFormat = "yyyy-MM-dd hh:mm tt";

$(function() 
{
    buildDatepicker();
    buildDatetimepicker();
    setStyleToForm();
});

function setStyleToForm()
{
    $(".form li").each(function()
    {
        $("div", $(this)).each(function(divIndex)
        {
            if (divIndex == 0)
            {
                $(this).css(
                {
                    "text-align":"left",
                    "width":"200px",                    
                    "padding-right":"5px"
                });
            }
            else
            {
                $(this).css(
                {
                    "text-align":"left"                    
                });
            }                        
        });
    });
}

function buildDatepicker()
{
    //$(".date").click(function() 
    $(".date").live("click", function() 
    {
        $(this).datepicker(
        {
            changeMonth: true,
            changeYear: true,
            dateFormat: dateFormat
        }).focus();
    });    
}

function buildDatetimepicker() 
{
    //$(".datetime").click(function() 
    $(".datetime").live('click', function() 
    {
        $(this).datetimepicker(
        {
            changeMonth: true,
            changeYear: true,
            dateFormat: dateTimeFormat
        }).focus();        
    });
}

function setStyleToDropdownList(ddlId, style, strIndices, separator)
{
    var ddl = document.getElementById(ddlId);
    if (ddl == null) 
    {        
        return;
    }
    
    var indices = strIndices.split(separator);
    if(indices[0] == "")
    {        
       return;
    }        
        
    for(i = 0; i < indices.length; i++)
    {        
        option = ddl.options[indices[i]];        
        option.style.color="brown";                        
    }                            
}
